<template>
  <div>
    <ul class="tab"
        ref="tabs">
      <router-link class="item"
                   :to="item.path"
                   :key="'home-tabs-' + index"
                   v-for="(item,index) in tabs"
                   exact-active-class="active">
        <span class="txt">{{item.name}}</span>
      </router-link>
    </ul>
  </div>
</template>

<script>
export default {
  name: 'tabs',
  data () {
    return {
      tabs: [
        { name: '首页', path: '/index' },
        { name: '提问', path: '/index/ask' },
        { name: '建议', path: '/index/advise' },
        { name: '分享', path: '/index/share' },
        { name: '讨论', path: '/index/discuss' }
      ]
    }
  },
  mounted () {
    const elem = this.$refs.tabs
    window.forbidScroll(elem)
  }
}
</script>

<style lang="scss" scoped>
.tab {
  display: flex;
  border-bottom: 1px solid $border-color;
  border-top: 1px solid $border-color;
  height: 80px;
  line-height: 80px;
  box-shadow: 0 1px 5px 0 rgba(0, 0, 0, 0.1);
  background-color: #fff;
  padding: 0;
  margin: 0;
  // margin-bottom: 20px;
  .item {
    flex: 1;
    text-align: center;
    color: #a9a9a9;
    .txt {
      display: inline-block;
      position: relative;
      &::before {
        content: '';
        display: none;
        position: absolute;
        left: 0;
        bottom: 0px;
        width: 100%;
        height: 4px;
        border-radius: 4px;
      }
    }
  }
  .active {
    color: #02d199;
    .txt {
      &::before {
        display: block;
        background-color: #02d199;
      }
    }
  }
}

</style>
